package com.example.redisdemo.controller;

import com.example.redisdemo.configuration.RabbitConfig;
import com.example.redisdemo.enums.RabbitEnum;
import com.example.redisdemo.service.Sender;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author hexinglin
 * @created 2021-08-11 14:54
 **/
@RestController
@RequestMapping("rabbit")
public class RabbitContronller {
    @Autowired
    private Sender sender;

    @RequestMapping("send")
    public String send(){
        String uuid= UUID.randomUUID().toString();
        sender.send(uuid);
        return uuid;
    }
    @RequestMapping("sendTimer")
    public String sendTimer(){
        String uuid= UUID.randomUUID().toString();
        sender.send(RabbitConfig.DELAY_EXCHANGE_NAME,RabbitConfig.DELAY_KEY,uuid);
        return uuid;
    }
}
